#include "Board.h"
#include "Pieces.h"

Board::Board() {

	cells = new Cell**[8];
	for (int i = 0; i < 8; i++) {
		cells[i] = new Cell*[8];
		for (int j = 0; j < 8; j++) {
			cells[i][j] = new Cell(this, i, j);
		}
	}
}
Board::~Board() {

	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			delete cells[i][j];
		}
		delete[](cells[i]);
	}
	delete[](cells);
}



Cell* Board::GetCell(int row, int col) {
	return cells[row][col];
}
std::string Board::toString(){
	std::string output = "<board>";
	for (int i = 0; i < 8; i++) {
		for (int j = 0; j < 8; j++) {
			if(cells[i][j]->GetPiece() != NULL)
				output += cells[i][j]->toString();
		}
	}
	output += "</board>";
	return output;
}